package com.itcoon.cloud.framework.security.ex;


import com.itcoon.cloud.framework.enums.CommonModule;
import com.itcoon.cloud.framework.enums.IModule;
import com.itcoon.cloud.framework.ex.errorcode.IModuleServiceErrorCode;
import org.springframework.security.core.AuthenticationException;

/**
 * @author Administrator
 * created in 2021/4/7
 */
public enum SecurityResponseEnum implements IModuleServiceErrorCode<AuthenticationException> {

	SECURITY_EXCEPTION("100", "安全认证异常"),
	ACCESS_UNAUTHORIZED("101", "受保护资源,请先登录"),
	ACCESS_FORBIDDEN("102", "无资源权限，拒绝访问"),
	BAD_CREDENTIALS("103", "错误密码"),
	USER_MISSING("104", "用户不存在"),
	USER_LOCKED("105", "用户被锁定"),
	BAD_CAPTCHA("106", "错误验证码"),
	TOKEN_EXPIRED("111", "访问令牌过期, 请刷新"),
	BAD_TOKEN("112", "访问令牌不正确"),
	TOKEN_LOCKED("113", "访问令牌被锁定"),
	REFRESH_TOKEN_EXPIRED("114", "刷新令牌过期"),
	REFRESH_TOKEN_MISMATCH("115", "刷新令牌不匹配"),
	USER_DISABLED("116", "用户被禁用");

	private final String code;
	private final String message;

	SecurityResponseEnum(String code, String message) {
		this.code = code;
		this.message = message;
	}

	@Override
	public AuthenticationException bindException() {
        return new AuthenticationException(this);
    }

	@Override
	public IModule getModule() {
		return CommonModule.COMMON;
	}

    @Override
    public String getMessage() {
        return message;
    }

	@Override
	public String getServiceCode() {
		return this.code;
	}
}
